package com.etc.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.etc.dao.AdminMapper;
import com.etc.entity.Admin;
import com.etc.service.AdminService;

@Service
public class AdminServiceImpl implements AdminService {

	@Resource
	private AdminMapper am;
	@SuppressWarnings("unlikely-arg-type")
	@Override
	public Map<String, Object>  login(String adminName, String adminPwd,HttpServletRequest request) {
		// TODO Auto-generated method stub
		
		Admin admin= am.selectAdmin(adminName, adminPwd);
		 Map<String, Object> map=new HashMap<>();
		if(admin==null) {
			  map.put("status", "userNameOrPwdError");
		}
		else if(admin!=null&&!"".equals(admin.getAdminId())) {
			 map.put("status", "ok");
	         map.put("admin", admin);
	         request.getSession().setAttribute("admin", admin);
		}
		
		return map;
	}

}
